﻿using System.Collections.Generic;
using System.Linq;
using BlankMvc.Dao.Entities.Base;

namespace BlankMvc.Dao.Repository.Base {
	public interface IRepository {
	}

	public interface IRepository<TEntity, in TPrimaryKey> : IRepository where TEntity : Entity<TPrimaryKey> {
		/// <summary>
		/// Used to get a IQueryable that is used to retrive entities from entire table.
		/// </summary>
		/// <returns>IQueryable to be used to select entities from database</returns>
		List<TEntity> All();

		/// <summary>
		/// Gets an entity.
		/// </summary>
		/// <param name="key">Primary key of the entity to get</param>
		/// <returns>Entity</returns>
		TEntity Get(TPrimaryKey key);

		/// <summary>
		/// Inserts a new entity.
		/// </summary>
		/// <param name="entity">Entity</param>
		void Insert(TEntity entity);

		/// <summary>
		/// Updates an existing entity.
		/// </summary>
		/// <param name="entity">Entity</param>
		void Update(TEntity entity);

		/// <summary>
		/// Deletes an entity.
		/// </summary>
		/// <param name="id">Id of the entity</param>
		void Delete(TPrimaryKey id);
	}
}
